//
//  Contact.m
//  HomeWork6-1
//
//  Created by dllo on 15/10/30.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "Contact.h"

@implementation Contact

- (id)initWithName:(NSString *)name sex:(NSString *)sex phone:(NSString *)phone age:(NSInteger)age
{
    self = [super init];
    if (self) {
        [self setName:name];
        [self setSex:sex];
        [self setPhone:phone];
        [self setAge:age];
    }
    return self;
}


- (NSComparisonResult)compareByNameOfContact:(Contact *)contact
{
    return [self.name compare:contact.name];
}

- (NSComparisonResult)compareByAgeOfContact:(Contact *)contact;
{
    if (self.age > contact.age) {
        return NSOrderedDescending;
    }
    if (self.age < contact.age) {
        return NSOrderedAscending;
    }
    return NSOrderedSame;
}




@end
